package com.fuhe.chen.vendingmachine.common;

import lombok.Data;

/**
 *  返回的参数封装类
 * Created by Administrator on 2020/3/6.
 */
@Data
public class LoginAPIResponse<T> {
    private static final String CODE_SUCCESS = "success";

    private static final String CODE_FAIL = "fail";

    private String code;

    private T data;

    private String msg;

    public LoginAPIResponse(String code) {
        this.code = code;
    }

    public LoginAPIResponse(String code, T data) {
        this.code = code;
        this.data = data;
    }

    public LoginAPIResponse(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static LoginAPIResponse success(){
        return new LoginAPIResponse(CODE_SUCCESS);
    }

    public static LoginAPIResponse success(Object data){
        return new LoginAPIResponse(CODE_SUCCESS,data);
    }

    public static LoginAPIResponse fail(String msg){
        return new LoginAPIResponse(CODE_FAIL,msg);
    }

    public static LoginAPIResponse withCode(String errorCode){
        return new LoginAPIResponse(errorCode);
    }


}
